const express = require("express");
const app = express();
const bodyParser = require("body-parser"); //解析参数
const { json } = require("express");
app.use(bodyParser.json({limit:'50mb'})); //json请求
app.use(bodyParser.urlencoded({limit:'50mb', extended: false })); //表单请求




// token校验
// const checkToken = require("./utils/checkToken");
// app.use(checkToken);

app.listen(3000, (_) => {
  console.log("服务启动成功！");
});

//设置跨域访问
app.all("*", function (req, res, next) {
  console.log( req.query ,req.body, "参数");
  res.header("Access-Control-Allow-Origin", "*");
  res.header(
    "Access-Control-Allow-Headers",
    "DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,authorization"
  );
  res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
  res.header("X-Powered-By", " 3.2.1");
  res.header("Content-Type", "application/x-www-form-urlencoded");
  res.header(" Access-Control-Allow-Headers");
  next();
});

const public = require("./router/user_public");
const user = require("./router/user");
const common = require("./router/common");
const comment = require("./router/comment");
const address = require("./router/address");
const video = require("./router/video");
// 任何路由信息都会执行这里面的语句
app.use("/api/user", public);
app.use("/api/user", user);
app.use("/api/common", common);
app.use("/api/comment", comment);
app.use("/api/address", address);
app.use("/api/video", video);
